<template>
  <div class="process-home">
    <h3>流程申请</h3>
    
    <el-row :gutter="20" class="process-list">
      <!-- 请假申请 -->
      <el-col :span="8">
        <el-card class="process-card" shadow="hover" @click="startProcess('leave')">
          <div class="process-icon">
            <i class="el-icon-date"></i>
          </div>
          <div class="process-info">
            <h4>请假申请</h4>
            <p>发起请假申请流程</p>
            <div class="process-stats">
              <span>本月已申请: 1次</span>
              <span>待审批: 0</span>
            </div>
          </div>
        </el-card>
      </el-col>

      <!-- 出差申请 -->
      <el-col :span="8">
        <el-card class="process-card" shadow="hover" @click="startProcess('business-trip')">
          <div class="process-icon">
            <i class="el-icon-location"></i>
          </div>
          <div class="process-info">
            <h4>出差申请</h4>
            <p>发起出差申请流程</p>
            <div class="process-stats">
              <span>本月已申请: 0次</span>
              <span>待审批: 0</span>
            </div>
          </div>
        </el-card>
      </el-col>

      <!-- 加班申请 -->
      <el-col :span="8">
        <el-card class="process-card" shadow="hover" @click="startProcess('overtime')">
          <div class="process-icon">
            <i class="el-icon-time"></i>
          </div>
          <div class="process-info">
            <h4>加班申请</h4>
            <p>发起加班申请流程</p>
            <div class="process-stats">
              <span>本月已申请: 2次</span>
              <span>待审批: 1</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 常用流程 -->
    <div class="frequent-process">
      <h3>常用流程</h3>
      <el-table :data="frequentProcesses" style="width: 100%">
        <el-table-column prop="name" label="流程名称" width="180"></el-table-column>
        <el-table-column prop="department" label="所属部门" width="180"></el-table-column>
        <el-table-column prop="useCount" label="使用次数"></el-table-column>
        <el-table-column label="操作" width="150">
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="startProcess(scope.row.type)">
              发起申请
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      frequentProcesses: [
        {
          name: '请假申请',
          department: '人事部',
          useCount: 10,
          type: 'leave'
        },
        {
          name: '加班申请',
          department: '人事部',
          useCount: 5,
          type: 'overtime'
        },
        {
          name: '出差申请',
          department: '人事部',
          useCount: 3,
          type: 'business-trip'
        }
      ]
    }
  },
  methods: {
    startProcess(type) {
      switch (type) {
        case 'leave':
          this.$router.push('/main/renshi/kaoqing/qingjia')
          break
        case 'business-trip':
          this.$router.push('/main/renshi/kaoqing/gwwaichu')
          break
        case 'overtime':
          this.$router.push('/main/renshi/kaoqing/jiabansq')
          break
        default:
          this.$message.warning('未知的流程类型')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.process-home {
  h3 {
    margin-bottom: 20px;
    color: #303133;
  }

  .process-list {
    margin-bottom: 30px;
  }

  .process-card {
    cursor: pointer;
    transition: all 0.3s;
    height: 100%;

    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
    }

    .process-icon {
      text-align: center;
      margin-bottom: 15px;

      i {
        font-size: 40px;
        color: #409EFF;
      }
    }

    .process-info {
      text-align: center;

      h4 {
        margin: 0 0 10px;
        font-size: 18px;
        color: #303133;
      }

      p {
        margin: 0 0 15px;
        font-size: 14px;
        color: #909399;
      }

      .process-stats {
        display: flex;
        justify-content: space-around;
        font-size: 12px;
        color: #606266;
      }
    }
  }

  .frequent-process {
    margin-top: 30px;
  }
}
</style> 